﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace QD.Snapshot.Core.BLL
{
    public class PromotionReport
    {
        /// <summary>
        /// 将新规则生成的HTML路径，更新到快照表中
        /// </summary>
        /// <param name="model"></param>
        public static int  InserOrUpdate(Model.Snap model)
        {
            int id = DAL.PromotionReport.GetId(model);
            if (id < 0) return -1;

            //更新平台ID
            if (id > 0)
                return DAL.PromotionReport.UpdateHtmlUrl(model, id);
            else
                return DAL.PromotionReport.Add(model);
        }



        /// <summary>
        /// 更新统计报表的数据
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static int InsertOrUpdateSnapshot(Model.Snap model) {
            int count = DAL.PromotionReport.UpdatePlatform(model.copyform.ToString(), model.platform);
            if (count <= 0)
                count = DAL.PromotionReport.AddPlatform(model.copyform.ToString(), model.platform);
            return count;
        }


        /// <summary>
        /// 检测是否存在
        /// </summary>
        /// <param name="model"></param>
        public static int IsExsits(Model.Snap model)
        {
            return DAL.PromotionReport.GetId(model);
        }
    }
}
